<!DOCTYPE html>
<html lang="zh-cn">
    <head>
        <meta charset="UTF-8"/>
        <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
        <title>Document</title>
    </head>
    <body>
        <h1>定义类</h1>
        <p>来源:<a href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Classes">https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Classes</a></p>
        <h3>类体和方法定义</h3>
        <ol>
            <li>类声明和类表达式都作用于严格模式下</li>
            <li>一个类只有一个构造函数</li>
            <li></li>
            <li></li>
            <li></li>
        </ol>
        <script>
            // 类声明
            let p = new Rectangle(); 
            class Rectangle {
              constructor(height, width) {
                this.height = height;
                this.width = width;
              }
            }
            // 类表达式，两种：匿名类、命名类
            /* 匿名类 */ 
            let Rectangle = class {
              constructor(height, width) {
                this.height = height;
                this.width = width;
              }
            };

            /* 命名的类 */ 
            let Rectangle = class Rectangle {
              constructor(height, width) {
                this.height = height;
                this.width = width;
              }
            };
            
        </script>
    </body>
</html>